import type { Preview } from "@storybook/react";
import "tailwindcss/tailwind.css";
import "../src/styles/tailwind.css";
import "tdesign-react/es/style/index.css";
import * as signalR from "@microsoft/signalr";
import iotDataService from "./../src/_common/service/IotDataService";
let connection = new signalR.HubConnectionBuilder()
  .withUrl("http://localhost:5063/egod/iot/real")
  .withHubProtocol(new signalR.JsonHubProtocol())
  .withAutomaticReconnect()
  .build();
connection.onclose(() => {
  console.log("signalr close:");
});
connection.onreconnecting(() => {
  console.log("signalr reconnecting:");
});
connection.on("RealTimeData", function (data) {
  iotDataService.upData(data);
});
connection
  .start()
  .then(() => {
    console.log("signalr start:");
  })
  .catch((err) => console.log(err));
const preview: Preview = {
  parameters: {
    controls: {
      matchers: {
        color: /(background|color)$/i,
        date: /Date$/i,
      },
    },
  },
};

export default preview;
